/*********************************************************************
	Rhapsody	: 7.5.2
	Login		: Administrator
	Component	: Test
	Configuration 	: DefaultConfig
	Model Element	: Engine
//!	Generated Date	: Wed, 1, Dec 2010 
	File Path	: Test/DefaultConfig/RobotPkg/Engine.java
*********************************************************************/

package RobotPkg;

//## auto_generated
import java.util.*;
//## auto_generated
import com.ibm.rational.rhapsody.animation.*;
//## auto_generated
import com.ibm.rational.rhapsody.animcom.animMessages.*;

//----------------------------------------------------------------------------
// RobotPkg/Engine.java                                                                  
//----------------------------------------------------------------------------

//## package RobotPkg 


//## class Engine 
public class Engine implements Animated {
    
    protected boolean direction;		//## attribute direction 
    
    protected int speed;		//## attribute speed 
    
    protected ArrayList<RobotController> itsRobotController;		//## link itsRobotController 
    
    //#[ ignore
    // Instrumentation attributes (Animation)
    private Animate animate;
    
    public static AnimClass animClassEngine = new AnimClass("RobotPkg.Engine",false);
    //#]
    
    
    // Constructors
    
    //## auto_generated 
    public  Engine() {
        try {
            animInstance().notifyConstructorEntered(animClassEngine.getUserClass(),
               new ArgData[] {
               });
        
        {
            itsRobotController = new ArrayList<RobotController>();
        }
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation getDirection() 
    public boolean getDirection() {
        try {
            animInstance().notifyMethodEntered("getDirection",
               new ArgData[] {
               });
        
        //#[ operation getDirection() 
        return direction;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation getSpeed() 
    public int getSpeed() {
        try {
            animInstance().notifyMethodEntered("getSpeed",
               new ArgData[] {
               });
        
        //#[ operation getSpeed() 
        return speed;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation setDirection(boolean) 
    public void setDirection(boolean direction) {
        try {
            animInstance().notifyMethodEntered("setDirection",
               new ArgData[] {
                   new ArgData(boolean.class, "direction", AnimInstance.animToString(direction))
               });
        
        //#[ operation setDirection(boolean) 
        this.direction = direction;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## operation setSpeed(int) 
    public void setSpeed(int speed) {
        try {
            animInstance().notifyMethodEntered("setSpeed",
               new ArgData[] {
                   new ArgData(int.class, "speed", AnimInstance.animToString(speed))
               });
        
        //#[ operation setSpeed(int) 
        this.speed = speed;
        //#]
        }
        finally {
            animInstance().notifyMethodExit();
        }
        
    }
    
    //## auto_generated 
    public ListIterator<RobotController> getItsRobotController() {
        ListIterator<RobotController> iter = itsRobotController.listIterator();
        return iter;
    }
    
    //## auto_generated 
    public void _addItsRobotController(RobotController p_RobotController) {
        if(p_RobotController != null)
            {
                animInstance().notifyRelationAdded("itsRobotController", p_RobotController);
            }
        else
            {
                animInstance().notifyRelationCleared("itsRobotController");
            }
        itsRobotController.add(0, p_RobotController);
    }
    
    //## auto_generated 
    public void addItsRobotController(RobotController p_RobotController) {
        if(p_RobotController != null)
            {
                p_RobotController._setItsEngine_1(this);
            }
        _addItsRobotController(p_RobotController);
    }
    
    //## auto_generated 
    public void _removeItsRobotController(RobotController p_RobotController) {
        animInstance().notifyRelationRemoved("itsRobotController", p_RobotController);
        itsRobotController.remove(p_RobotController);
    }
    
    //## auto_generated 
    public void removeItsRobotController(RobotController p_RobotController) {
        if(p_RobotController != null)
            {
                p_RobotController.__setItsEngine_1(null);
            }
        _removeItsRobotController(p_RobotController);
    }
    
    //## auto_generated 
    public void _clearItsRobotController() {
        animInstance().notifyRelationCleared("itsRobotController");
        itsRobotController.clear();
    }
    
    //## auto_generated 
    public void clearItsRobotController() {
        ListIterator<RobotController> iter = itsRobotController.listIterator();
        while (iter.hasNext()){
            (itsRobotController.get(iter.nextIndex()))._clearItsEngine_1();
            iter.next();
        }
        _clearItsRobotController();
    }
    
    //#[ ignore
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimClass getAnimClass() { 
        return animClassEngine; 
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public Object getFieldValue(java.lang.reflect.Field f, Object userInstance) { 
         Object obj = null;
         try {
             obj = f.get(userInstance);
         } catch(Exception e) {
              System.err.println("Exception: getting Field value: " + e);
              e.printStackTrace();
         }
         return obj;
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public AnimInstance animInstance() {
        if (animate == null) 
            animate = new Animate(); 
        return animate; 
    } 
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addAttributes(AnimAttributes msg) {
        
        msg.add("speed", speed);
        msg.add("direction", direction);
    }
    /**  see com.ibm.rational.rhapsody.animation.Animated interface */
    public void addRelations(AnimRelations msg) {
        
        msg.add("itsRobotController", false, false, itsRobotController);
    }
    /** An inner class added as instrumentation for animation */
    public class Animate extends AnimInstance { 
        public  Animate() { 
            super(Engine.this); 
        } 
        public void addAttributes(AnimAttributes msg) {
            Engine.this.addAttributes(msg);
        }
        public void addRelations(AnimRelations msg) {
            Engine.this.addRelations(msg);
        }
        
    } 
    //#]
    
}
/*********************************************************************
	File Path	: Test/DefaultConfig/RobotPkg/Engine.java
*********************************************************************/

